package com.free.front.controller.product;

import com.free.common.vo.ResultModel;
import com.free.front.bf.product.ProductVinAlibabaBf;
import com.free.front.util.Mu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@Controller
public class ProductByVinAlibabaController {
    @Autowired
    private ProductVinAlibabaBf  vinAlibabaBf;

    /**
     * 图片识别vin码
     * @param file 图片路径
     * @return
     * {
     *   "success": true,
     *   "vin": "LSGPB54R4DD331665",
     *   "request_id": 20171031122455
     * }
     */
    @RequestMapping("/identificationVinCode.json")
    @ResponseBody
    public ResultModel identificationVinCode(MultipartFile file){
        return vinAlibabaBf.identificationVinCode(file);
    }

    /**
     * 图片识别行驶证
     * @param file   图片路径
     * @return
     * 正面
     * {
     *     "config_str": "null\n",         #配置字符串信息
     *     "plate_num": "沪A0M084",        #车牌号码
     *     "vehicle_type":"小型轿车",       #车辆类型
     *     "owner": "张三",                #所有人名称
     *     "use_character":"出租转非",      #使用性质
     *     "addr":"浙江省宁波市江东区丁街88弄", #地址
     *     "model":"桑塔纳牌SVW7180LE1",    #品牌型号
     *     "vin" : "LSVFF66R8C2116280",     #车辆识别代号
     *     "engine_num" : "416098",        #发动机号码
     *     "register_date":"20121127",       #注册日期
     *     "issue_date":"20130708",        #发证日期
     *     "request_id": "84701974fb983158_20160526100112",               #请求对应的唯一表示
     *     "success": true                 #识别成功与否 true/false
     * }
     */
    @RequestMapping("/drivinglicense.json")
    @ResponseBody
    public ResultModel drivinglicense(MultipartFile file){
        return vinAlibabaBf.drivinglicense(file);
    }

    @RequestMapping("/alivinAnalyze.json")
    @ResponseBody
    public ResultModel alivinAnlayze(@RequestParam MultipartFile file, HttpServletRequest request){
        return vinAlibabaBf.getByVinFile(file);
    }

}
